﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media;
using Eventhere.Work;
using System.IO.IsolatedStorage;

namespace Eventhere.Repert
{
    public partial class RepertoryModel : PhoneApplicationPage
    {
        GroupContact groupe;
        public RepertoryModel()
        {
            
            if (IsolatedStorageSettings.ApplicationSettings.Contains("GroupId"))
                this.groupe = (GroupContact)IsolatedStorageSettings.ApplicationSettings["GroupId"];
            
            IsolatedStorageSettings.ApplicationSettings["GroupId"] = null;
            InitializeComponent();
            this.OptionPane.Cancel += OptionPane_Cancel;
            this.OptionPane.AddUser += OptionPane_AddUser;
            this.OptionPane.EditUser += OptionPane_EditUser;
            this.OptionPane.RemoveUser += OptionPane_RemoveUser;


            this.NamePage.Text = this.groupe.NameGroupContact.ToUpper();

            Visibility darkBackgroundVisibility = (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];
            // le thème est sombre
            

            foreach (Contact c in this.groupe.ContactGroupContact)
            {
                Button Unbutton = new Button();
                Unbutton.Content = "NomContact";

                if (c == this.groupe.ContactGroupContact.First())
                    Unbutton.Margin = new Thickness(0, 0, 0, 0);
                else
                    Unbutton.Margin = new Thickness(0, -25, 0, 0);
                if (darkBackgroundVisibility == Visibility.Visible) // theme sombre
                    Unbutton.BorderBrush = new SolidColorBrush(Colors.White);
                else
                    Unbutton.BorderBrush = new SolidColorBrush(Colors.Black); //theme clair
                Unbutton.Height = 100;
                Unbutton.BorderThickness = new Thickness(1);
                Unbutton.Padding = new Thickness(10, 0, 0, 0);
                Unbutton.UseLayoutRounding = true;
                Unbutton.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
                this.ContentRepertoryPanel.Children.Add(Unbutton);
            }
  
        }

        private void OptionPane_EditUser(object arg1, EventArgs arg2)
        {
            
        }

        private void OptionPane_RemoveUser(object arg1, EventArgs arg2)
        {
            
        }

        private void OptionPane_AddUser(object arg1, EventArgs arg2)
        {
            
        }

        private void OptionPane_Cancel(object arg1, EventArgs arg2)
        {
            
        }
    }
}